<!--
Copyright 2017 The Kubernetes Dashboard Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<kd-info-card>
  <kd-info-card-header ng-transclude="header">
    [[Containers|Subtitle at the top of the container details.]]
  </kd-info-card-header>
  <kd-info-card-section ng-repeat="container in ::$ctrl.containers"
                        name="{{::container.name}}">
    <kd-info-card-entry title="[[Image|Label for container image.]]">
      {{::container.image}}
    </kd-info-card-entry>
    <kd-info-card-entry title="[[Environment variables|Label for container environment variables.]]">
      <div ng-if="::container.env.length">
        <div ng-repeat="env in ::container.env"
             layout="row">
          <span>{{::env.name}}</span><span ng-if="env.valueFrom">
            <span ng-if="env.valueFrom.configMapKeyRef">
              (<a ng-href="{{::$ctrl.getEnvConfigMapHref(env.valueFrom.configMapKeyRef)}}">
                [[value from ConfigMap {{env.valueFrom.configMapKeyRef.Name}}/{{env.valueFrom.configMapKeyRef.key}}|Label for environment variable that comes from a Config Map]]
              </a>)
            </span>
          </span><span>:&nbsp;</span>
          <kd-middle-ellipsis display-string="{{::env.value}}"
                              flex="shrink">
          </kd-middle-ellipsis>
        </div>
      </div>
      <div ng-if="::!container.env.length">
        [[-|Label when there is no container environment variables.]]
      </div>
    </kd-info-card-entry>
    <kd-info-card-entry title="[[Commands|Label for container commands.]]">
      <div ng-if="::container.commands.length">
        <div ng-repeat="(key, value) in ::container.commands"
             layout="row">
          <kd-middle-ellipsis display-string="{{::value}}"
                              flex="shrink">
            <kd-middle-ellipsis>
        </div>
      </div>
      <div ng-if="::!container.commands.length">
        [[-|Label when there is no container commands.]]
      </div>
    </kd-info-card-entry>
    <kd-info-card-entry title="[[Args|Label for container args.]]">
      <div ng-if="::container.args.length">
        <div ng-repeat="(key, value) in ::container.args"
             layout="row">
          <kd-middle-ellipsis display-string="{{::value}}"
                              flex="shrink">
            <kd-middle-ellipsis>
        </div>
      </div>
      <div ng-if="::!container.args.length">
        [[-|Label when there is no container arguments.]]
      </div>
    </kd-info-card-entry>
    <kd-info-card-entry ng-if="::$ctrl.podName">
      <a ng-href="{{::$ctrl.getLogsHref(container)}}"
         class="kd-middle-ellipsised-link">
        <kd-middle-ellipsis display-string="[[View logs|Label for the container logs.]]">
        </kd-middle-ellipsis>
      </a>
      <a ng-href="{{::$ctrl.getShellHref(container)}}"
         class="kd-middle-ellipsised-link">
        <kd-middle-ellipsis display-string="[[Execute shell|Execute shell in the container]]">
        </kd-middle-ellipsis>
      </a>
    </kd-info-card-entry>
  </kd-info-card-section>
</kd-info-card>
